import requests
import json

base_url = 'http://localhost:5000'

# 定义请求模板
def send_rpc_request(method, params):
    payload = {
        "jsonrpc": "2.0",
        "method": method,
        "params": params,
        "id": 1  # 可以自动生成唯一ID
    }
    
    response = requests.post(f"{base_url}/rpc", json=payload)
    return response.json()

# 测试正确方法
response = send_rpc_request('add', [1, 2])
print("Test 'add':", response)

# 测试错误方法
response = send_rpc_request('multiply', [3, 4])
print("Test 'multiply':", response)

# 测试存在语法错误的方法
response = send_rpc_request('subtract', {"minuend": 5, "subtrahend": 3})
print("Test 'subtract':", response)